<%= render Polaris::BaseComponent.new(**@system_arguments) do %>
  <% if @title.present? && @title.is_a?(String) %>
    <div class="Polaris-LegacyCard__SectionHeader">
      <% if @actions.present? %>
        <%= polaris_stack(alignment: :trailing) do |stack| %>
          <% stack.with_item(fill: true) do %>
            <%= polaris_text(variant: :headingSm, as: :h3) { @title } %>
          <% end %>

          <% stack.with_item do %>
            <%= polaris_button_group do |group| %>
              <% @actions.each do |action| %>
                <% group.with_button(**action) %>
              <% end %>
            <% end %>
          <% end %>
        <% end %>
      <% else %>
        <%= polaris_text(variant: :headingSm, as: :h3) { @title } %>
      <% end %>
    </div>
  <% end %>

  <% if subsections.present? %>
    <% subsections.each do |subsection| %>
      <%= subsection %>
    <% end %>
  <% else %>
    <%= content %>
  <% end %>
<% end %>
